//:C06:copy_if.h
// Create your own STL_style algorithm.
#ifndef COPY_IF_H
#define COPY_IF_H
template<typename ForwardIter,typename OutputIter, typename UnaryPred>
OutputIter copy_if(ForwardIter begin, ForwardIter end,
  OutputIter dest, UnaryPred f)
{
    while(begin != end)
    {
        if(f(*begin))
        {
            *dest++ = *begin;
        }
        ++begin;
    }
    return dest;
}  
#endif